/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sv.com.bolsaTrabajo.model.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author sysmanager
 */
@Entity
@Table(name = "detalle_publicacion", catalog = "bolsadetrabajo", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DetallePublicacion.findAll", query = "SELECT d FROM DetallePublicacion d"),
    @NamedQuery(name = "DetallePublicacion.findByIdDetallePub", query = "SELECT d FROM DetallePublicacion d WHERE d.idDetallePub = :idDetallePub"),
    @NamedQuery(name = "DetallePublicacion.findByDescripcion", query = "SELECT d FROM DetallePublicacion d WHERE d.descripcion = :descripcion")})
public class DetallePublicacion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_detalle_pub", nullable = false)
    private Integer idDetallePub;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(nullable = false, length = 255)
    private String descripcion;
    @JoinColumn(name = "id_publicacion", referencedColumnName = "id_publicacion", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Publicacion idPublicacion;

    public DetallePublicacion() {
    }

    public DetallePublicacion(Integer idDetallePub) {
        this.idDetallePub = idDetallePub;
    }

    public DetallePublicacion(Integer idDetallePub, String descripcion) {
        this.idDetallePub = idDetallePub;
        this.descripcion = descripcion;
    }

    public Integer getIdDetallePub() {
        return idDetallePub;
    }

    public void setIdDetallePub(Integer idDetallePub) {
        this.idDetallePub = idDetallePub;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Publicacion getIdPublicacion() {
        return idPublicacion;
    }

    public void setIdPublicacion(Publicacion idPublicacion) {
        this.idPublicacion = idPublicacion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDetallePub != null ? idDetallePub.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetallePublicacion)) {
            return false;
        }
        DetallePublicacion other = (DetallePublicacion) object;
        if ((this.idDetallePub == null && other.idDetallePub != null) || (this.idDetallePub != null && !this.idDetallePub.equals(other.idDetallePub))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sv.com.bolsaTrabajo.controller.DetallePublicacion[ idDetallePub=" + idDetallePub + " ]";
    }
    
}
